package On_class.L0317;

public class ThrowTest {
    public static void main(String[] args) {
        int[] arr={1,2,3};
        int index=3;

        int ele=getElement(arr,index);

    }
    private static int getElement(int[] arr,int index){
        if(index<0||index>arr.length){
            //抛出异常
            throw new ArrayIndexOutOfBoundsException("下标越界");

        }
        return arr[index];
    }
}
